﻿@{
    Layout = null;
}
@model  RiderShop.Mobile.Modle.Purchase.GreetingOrderModel
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>2015 Happy New Year!</title>
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
    <link rel="stylesheet" href="~/Themes/RongJi/Style/greetingcard/css/app.css">
    <link href="~/Themes/RongJi/Style/greetingcard/js/joyride-2.1.css" rel="stylesheet" />
    <link href="~/Themes/Common/assert/plugins/sweetalert-1.0/lib/sweet-alert.css" rel="stylesheet" />
</head>
<body>
    <div class="cardBody @Request.QueryString["CardId"]">
        <div class="audioPlayer">
            <a href="~/Themes/RongJi/Style/greetingcard/audio/@Html.Raw(@Request.QueryString["CardId"] + ".mp3")" title="" class="sm2_button"></a>
        </div>
        <div class="texts">
            <div class="to">亲爱的朋友</div>
            <div class="greetings">时间向前，又是一年。2015新春伊始，真诚送上我的祝福，愿你新春快乐，万事如意！</div>
            <div class="from">你的朋友</div>
        </div>
        <div class="diyTool">
            <button id="diy">定制</button>
            <button id="goBack" onclick="history.go(-1)">发送</button>
        </div>
    </div>
    <div class="sendTips"></div>
    <div class="diyBox">
        <form class="form-horizontal" action="~/Purchase/ConfirmGreetingCard" method="post" id="previewGreetingCardForm">
            <div class="diyBoxInner">
                <label>收卡人</label>
                <input name="RecipientName" maxlength="20" id="recipientName" type="text" value="@(Model.OrderGreetingCardInfo == null ? "": Model.OrderGreetingCardInfo.RecipientName)" placeholder="收卡人">
                <label>祝福词（不能超过60字）</label>
                <textarea name="Content" id="content" rows="4" maxlength="60" placeholder="祝福词">@((Model.OrderGreetingCardInfo == null || string.IsNullOrEmpty(Model.OrderGreetingCardInfo.Content)) ? "时间向前，又是一年。2015新春伊始，真诚送上我的祝福，愿你新春快乐，万事如意！" : Model.OrderGreetingCardInfo.Content)</textarea>
                <label>发卡人</label>
                <input name="CustomerUserName" maxlength="20" id="customerUserName" type="text" value="@(Model.OrderGreetingCardInfo == null ? Kevin.Shop.Business.Service.Entity.Helper.WebClientContext.Current.CurrentUser.RealName: Model.OrderGreetingCardInfo.CustomerUserName)" placeholder="发卡人">
                <div class="btn-groups">
                    <input type="hidden" value="@Request.QueryString["OrderNumber"]" name="OrderNumber" id="orderNumber">
                    <input type="hidden" value="@Request.QueryString["CardId"]" name="CardId" id="cardId">
                    <button class="btn btnCancel" type="button">取消</button>
                    <button class="btn btnSubmit" id="btnPreview" type="button">预览</button>
                </div>
            </div>
        </form>
    </div>
    <ol id="joyRideTipContent">
        <li data-id="diy" data-text="关闭">
            <h2>定制贺卡</h2>
            <p>定制您的贺卡祝福语及收卡人</p>
        </li>
    </ol>
    <script type="text/javascript" src="~/Themes/RongJi/Style/greetingcard/js/jquery.min.js"></script>
    <script type="text/javascript" src="~/Themes/RongJi/Style/greetingcard/js/soundmanager2-jsmin.js"></script>
    <script type="text/javascript" src="~/Themes/RongJi/Style/greetingcard/js/mp3-player-button.js"></script>
    <script type="text/javascript" src="~/Themes/RongJi/Style/greetingcard/js/app.js"></script>
    <script src="~/Utility/pages/pg_common.js"></script>
    <script type="text/javascript" src="~/Themes/RongJi/Style/greetingcard/js/jquery.joyride-2.1.js"></script>
    <script src="~/Themes/Common/assert/plugins/sweetalert-1.0/lib/sweet-alert.js" charset="gb2312"></script>
</body>
</html>

<script>
    $(document).ready(function () {

        $('#btnPreview').on('click', function () {
            if ($.trim($("#recipientName").val()) == '') {
                KevinShop.MessageBox.Alert('请输入收卡人！');
                return false;
            }
            if ($.trim($("#content").val()) == '') {
                KevinShop.MessageBox.Alert('请输入祝福词！');
                return false;
            }
            if ($.trim($("#customerUserName").val()) == '') {
                KevinShop.MessageBox.Alert('请输入发卡人！');
                return false;
            }

            var postData = $('#previewGreetingCardForm').serialize();
            var formUrl = $('#previewGreetingCardForm').attr("action");
            var orderNumber = $('#orderNumber').val();
            var cardId = $('#cardId').val();

            $.ajax({
                type: "POST",
                url: formUrl,
                dataType: "JSON",
                data: postData,
                success: function (response) {
                    if (response.Status) {
                        window.location.href = '/Purchase/PreviewCardGreetingCard?orderNumber=' + orderNumber + '&cardId=' + cardId;
                    }
                },
                error: function (err) {
                    KevinShop.MessageBox.Alert('预览失败！');
                    return false;
                }
            });

            var _to = $('input[name=to]').val();
            var _greetings = $('textarea[name=greetings]').val();
            var _from = $('input[name=from]').val();

            $('.to').text(_to);
            $('.greetings').text(_greetings);
            $('.from').text(_from);

            var box = $('.diyBox');
            var card = $('.cardBody');
            box.fadeOut();
            card.removeClass('blurIt');
        });
    });
</script>
